/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.fpuna.ii.electiva2.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Lauri
 */
@Entity
@Table(name = "venta")
@NamedQueries({@NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v"), 
                @NamedQuery(name = "Venta.findByVentCodigo", query = "SELECT v FROM Venta v WHERE v.ventCodigo = :ventCodigo"),
                @NamedQuery(name = "Venta.findByVentCantidad", query = "SELECT v FROM Venta v WHERE v.ventCantidad = :ventCantidad")})
public class Venta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id

    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="venta_seq_generator")
    @SequenceGenerator(name="venta_seq_generator", sequenceName="venta_vent_codigo_seq", allocationSize=1)

    @Basic(optional = false)
    @Column(name = "vent_codigo")
    private Integer ventCodigo;
    @Column(name = "vent_cantidad")
    private Integer ventCantidad;
    @JoinColumn(name = "vent_cliente", referencedColumnName = "clie_codigo")
    @ManyToOne
    private Cliente ventCliente;
    @JoinColumn(name = "vent_producto", referencedColumnName = "prod_codigo")
    @ManyToOne
    private Producto ventProducto;

    public Venta() {
    }

    public Venta(Integer ventCodigo) {
        this.ventCodigo = ventCodigo;
    }

    public Integer getVentCodigo() {
        return ventCodigo;
    }

    public void setVentCodigo(Integer ventCodigo) {
        this.ventCodigo = ventCodigo;
    }

    public Integer getVentCantidad() {
        return ventCantidad;
    }

    public void setVentCantidad(Integer ventCantidad) {
        this.ventCantidad = ventCantidad;
    }

    public Cliente getVentCliente() {
        return ventCliente;
    }

    public void setVentCliente(Cliente ventCliente) {
        this.ventCliente = ventCliente;
    }

    public Producto getVentProducto() {
        return ventProducto;
    }

    public void setVentProducto(Producto ventProducto) {
        this.ventProducto = ventProducto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ventCodigo != null ? ventCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Venta)) {
            return false;
        }
        Venta other = (Venta) object;
        if ((this.ventCodigo == null && other.ventCodigo != null) || (this.ventCodigo != null && !this.ventCodigo.equals(other.ventCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.fpuna.ii.electiva2.entity.Venta[ventCodigo=" + ventCodigo + "]";
    }

}
